<template>
	<view class="content">
		<view class="" v-if="Object.keys(clinic_userinfo).length > 0">


			<view style="height: 200rpx;width: 100%;background-color: #1262DB;"></view>
			<view class="wid90 mar borRad20 box" style="height: 260rpx;background-color: #fff;margin-top: -130rpx;">
				<view class="dis disAl hei60" style="justify-content: flex-end;width: 100%;">
					<!-- <image src="../../static/personalCenter/bianji.png" @click="tiaozhuan('/pages/device/clinic_info')"
						style="width: 32rpx;height: 32rpx;margin-right: 30rpx;"></image>
					<image src="../../static/personalCenter/shebei.png"
						style="width: 36rpx;height: 30rpx;margin-right: 30rpx;"></image> -->
				</view>
				<view class="wid80 mar dis disAl">
					<image :src="clinic_userinfo.avatar" style="width: 124rpx;height: 124rpx;" class="borRad50"></image>
					<view style="margin-left: 40rpx;">
						<view style="" class="foSi50">{{clinic_userinfo.user}}</view>
						<view style="color: #7C7C7C;" class="foSi30 mar-top10">{{clinic_userinfo.name}}</view>
						<!-- <view style="" class="foSi25 mar-top10">下属成员：{{clinic_userinfo.subordinate}}人</view> -->
					</view>
				</view>
			</view>
			<view style="height: 70rpx;background-color: #C5DBFC;" class="mar-top30 mar-bott30">
				<view class="wid90 mar dis disAl hei100">
					<view style="width: 20%;">
						<image src="../../static/personalCenter/gonggao.png" style="width: 44rpx;height: 40rpx;"
							class="mar-left10"></image>
					</view>
					<swiper class="wid80 hei100" :autoplay="true" :vertical="true" :circular='true'>
						<swiper-item v-for="(item,index) in 10" :key="index" class="wh100 dis disAl">
							<view class="foSi25" style="color: #1262DB;">{{clinic_userinfo.user_center_notes}}</view>
						</swiper-item>
					</swiper>
				</view>
			</view>

			<view class="wid90 mar borRad20 mar-top30;"
				style="background-color: #fff;display: flex;justify-content: space-around;padding: 20rpx 0rpx;">

				<view class="" style="display: flex;flex-direction: column;align-items: center;" @click="xiadan">
					<view class="">
						<image :src="url+icons[0]" style="width:80rpx;height:80rpx" mode=""></image>
					</view>
					<view class="ct">
						去下单
					</view>
				</view>
				<view class="" style="display: flex;flex-direction: column;align-items: center;" @click="tiaozhuan('/pages/checkorder/clinicorder?status=1')">
					<view class="">
						<image :src="url+icons[1]" style="width:80rpx;height:80rpx" mode=""></image>
					</view>
					<view class="ct">
						待支付
					</view>
				</view>
				<view class="" style="display: flex;flex-direction: column;align-items: center;" @click="tiaozhuan('/pages/checkorder/clinicorder?status=2')">
					<view class="">
						<image :src="url+icons[2]" style="width:80rpx;height:80rpx" mode=""></image>
					</view>
					<view class="ct">
						检测中
					</view>
				</view>

				<view class="" style="display: flex;flex-direction: column;align-items: center;" @click="tiaozhuan('/pages/checkorder/clinicorder?status=3')">
					<view class="">
						<image :src="url+icons[3]" style="width:80rpx;height:80rpx" mode=""></image>
					</view>
					<view class="ct">
						已完成
					</view>
				</view>
				<!-- <view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/device/clinic_info')">
					<view class="dis">
						<view class="dis disJuC" style="width: 75rpx;">
							<image src="../../static/personalCenter/zensuo.png" style="width: 50rpx;height: 39rpx;">
							</image>
						</view>
						<view>诊所信息</view>
					</view>
					<uni-icons type="forward" size="20" color="#616363"></uni-icons>
				</view>
				<view class="xhx"></view>
				<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/device/analysis')">
					<view class="dis">
						<view class="dis disJuC" style="width: 75rpx;">
							<image src="../../static/personalCenter/dingdan.png" style="width: 50rpx;height: 39rpx;">
							</image>
						</view>
						<view>统计分析</view>
					</view>
					<uni-icons type="forward" size="20" color="#616363"></uni-icons>
				</view> -->
				<!-- <view class="xhx"></view>
				<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/device/payok')">
					<view class="dis">
						<view class="dis disJuC" style="width: 75rpx;">
							<image src="../../static/personalCenter/dingdan.png" style="width: 50rpx;height: 39rpx;">
							</image>
						</view>
						<view>支付页面</view>
					</view>
					<uni-icons type="forward" size="20" color="#616363"></uni-icons>
				</view> -->

			</view>
			<view style="height: 30rpx;"></view>
			<view class="wid90 mar borRad20" style="height: 75px;background-color: #fff;">
				<view class="wid90 mar dis disAl"
					style="height: 75pxr;justify-content: space-around;padding-top: 10px;">
					<view class="textCen" style="width: 33.33%;" @click="tiaozhuan('/pages/device/analysis_list')"  v-if="clinic_login.clinic_auth == 1"> 
						<view v-if="!yxTrue" class="foSi50" style="color: #1262DB;">****</view>
						<view v-if="yxTrue" class="foSi50" style="color: #1262DB;">{{clinic_userinfo.today_income}}
						</view>
						<view class="foSi25" style="color: #7C7C7C;">今日检测收益</view>
					</view>
					<view class="textCen" style="width: 33.33%;"  v-if="clinic_login.clinic_auth == 2">
						<view v-if="!yxTrue" class="foSi50" style="color: #1262DB;">****</view>
						<view v-if="yxTrue" class="foSi50" style="color: #1262DB;">{{clinic_userinfo.today_income}}
						</view>
						<view class="foSi25" style="color: #7C7C7C;">今日检测收益</view>
					</view>
					<view class="textCen poRel" style="width: 33.33%;" v-if="clinic_userinfo.group_type == 2" @click="tiaozhuan('/pages/clinic/withdrawal?types=2')">
						<view v-if="!yxTrue" class="foSi50" style="color: #1262DB;">****</view>
						<view v-if="yxTrue" class="foSi50" style="color: #1262DB;">
							￥{{parseFloat(clinic_userinfo.rea_money).toFixed(2)}}</view>
						<view class="foSi25" style="color: #7C7C7C;">试剂成本</view>
					</view>
					<view class="textCen poRel" style="width: 33.33%;" v-if="clinic_login.clinic_auth == 1"
						@click="tiaozhuan('/pages/device/analysis_list')">
						<view v-if="!yxTrue" class="foSi50" style="color: #1262DB;">****</view>
						<view v-if="yxTrue" class="foSi50" style="color: #1262DB;">
							￥{{parseFloat(clinic_userinfo.device_deposit).toFixed(2)}}</view>
						<image v-if="!yxTrue" @click.stop="yxTrue = !yxTrue"
							src="../../static/personalCenter/yincang.png"
							style="width: 31rpx;height: 20rpx;right: -10rpx;top: 15rpx;" class="poAbs"></image>
						<image v-if="yxTrue" @click.stop="yxTrue = !yxTrue"
							src="../../static/personalCenter/xianshi.png"
							style="width: 31rpx;height: 20rpx;right: -10rpx;top: 15rpx;" class="poAbs"></image>
						<view class="foSi25" style="color: #7C7C7C;">设备押金</view>
					</view>
					<view class="textCen poRel" style="width: 33.33%;" v-if="clinic_login.clinic_auth ==2">
						<view v-if="!yxTrue" class="foSi50" style="color: #1262DB;">****</view>
						<view v-if="yxTrue" class="foSi50" style="color: #1262DB;">
							￥{{parseFloat(clinic_userinfo.device_deposit).toFixed(2)}}</view>
						
						<view class="foSi25" style="color: #7C7C7C;">设备押金</view>
					</view>
				</view>
			</view>

			<view class="wid90 mar borRad20 mar-top30;" style="background-color: #fff;display: flex;padding: 20rpx 0rpx;flex-direction: row;flex-wrap: wrap;">

				<view class="" @click="tiaozhuan(item.link_url)" style="display: flex;flex-direction: column;align-items: center;width:33%;margin-bottom: 20rpx;" v-for="(item,index) in fun_list" v-if="clinic_login.clinic_auth <= item.auths">
					
				
					<view class="">
						<image :src="url+item.icons" style="width:80rpx;height:80rpx" mode=""></image>
					</view>
					<view class="ct">
						{{item.name}}
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				yxTrue: false,
				clinic_userinfo: {},
				clinic_login:{},
				url: this.global.url,
				icons: [
					'wechatimg/zl1.png',
					'wechatimg/zl2.png',
					'wechatimg/zl3.png',
					'wechatimg/zl4.png',
				],
				group_id: 1,
				fun_list:[
					{
						name:'诊所信息',
						icons:'wechatimg/ys/c1.png',
						link_url:'/pages/device/clinic_info',
						auths:3
					},{
						name:'统计分析',
						icons:'wechatimg/ys/c2.png',
						link_url:'/pages/device/analysis',
						auths:1
					},{
						name:'全部订单',
						icons:'wechatimg/ys/c3.png',
						link_url:'/pages/device/analysis_list',
						auths:1
					},
					{
						name:'医生管理',
						icons:'wechatimg/ys/c4.png',
						link_url:'/pages/clinic/doctorlist',
						auths:1
					},
					{
						name:'诊所管理',
						icons:'wechatimg/ys/c5.png',
						link_url:'/pages/clinic/clinic_list',
						auths:3
					},{
						name:'患者管理',
						icons:'wechatimg/ys/c6.png',
						link_url:'/pages/clinic/patient',
						auths:3
					},{
						name:'设备管理',
						icons:'wechatimg/ys/c7.png',
						link_url:'/pages/clinic/devicelist',
						auths:3
					},
					{
						name:'提现管理',
						icons:'wechatimg/ys/c8.png',
						link_url:'/pages/clinic/withdrawal?types=1',
						auths:1
					},
					{
						name:'协议管理',
						icons:'wechatimg/ys/c9.png',
						link_url:'/pages/clinic/agreement',
						auths:1
					},
					{
						name:'打印机',
						icons:'wechatimg/ys/c9.png',
						link_url:'/pages/device/printer',
						auths:3
					}
				]
			}
		},
		onLoad() {
			this.clinic_data()
			this.clinic_login = uni.getStorageSync('clinic_userinfo')
			console.log(this.clinic_login)

		},
		methods: {
			xiadan(){
				if(this.clinic_userinfo.device_no == ''){	
					return this.tips('未绑定设备无法下单')
				}else{
					uni.navigateTo({
						url:'/pages/checkorder/checkorder?scene='+this.clinic_userinfo.device_no+"&identity=5"
					})
				}
			},
			clinic_data() {
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				uni.request({
					url: this.global.url + 'api/device/device_info',
					method: 'POST',
					data: {
						clinic_id: uni.getStorageSync('clinic_id')
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							// 存用户信息
							that.clinic_userinfo = result.data
							console.log(that.clinic_userinfo)
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'none'
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				})
			},


			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				});
			},
			
			tips(msg){
				uni.showModal({
				        title: '提示',
				        content: msg,
						showCancel:false,
				        success: function(res) {
				        if (res.confirm) {
				            // 执行确认后的操作
				        } 
				        else {
				            // 执行取消后的操作
				        }
				    }
				})
			}

		}
	}
</script>

<style>
	.content {
		background-color: #F0F0F0;
		min-height: 100vh;
	}

	.ct {
		font-size: 26rpx;
	}
</style>